/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sn.metier;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Set;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.ManyToMany;
import javax.persistence.OneToMany;

/**
 *
 * @author chenry08
 */
@Entity
public class Personne implements Serializable {
        public static final String DEFAULT_AVATAR = "img/no-avatar.jpg";
    
	//attributs
        @Id
        @GeneratedValue(strategy=GenerationType.AUTO)
	private Long id;
        
        @Column
	private String nom;
        
        @Column
	private String prenom;
        
        @Column
	private String pseudo;
        
        @Column
	private String avatar = DEFAULT_AVATAR;
        
        @Column
	private String email;
        
        @Column
	private String passwd;
       
        @ManyToMany
	private List<Personne> amis = new ArrayList<Personne>();
	
	//constructeurs

	public Personne() {}

	public Personne(Long id) {
		this.id = id;
	}

	public Personne(Long id, String nom, String prenom, String pseudo, String avatar, String email, String passwd) {
		this.id = id;
		this.nom = nom;
		this.prenom = prenom;
		this.pseudo = pseudo;
		this.avatar = avatar;
		this.email = email;
		this.passwd = passwd;
	}

        public Personne(String nom, String prenom, String pseudo, String email, String passwd) {
            this.nom = nom;
            this.prenom = prenom;
            this.pseudo = pseudo;
            this.email = email;
            this.passwd = passwd;
        }

        public Personne(Long id, String pseudo, String avatar, String email) {
            this.id = id;
            this.pseudo = pseudo;
            this.avatar = avatar;
            this.email = email;
        }


        
	//get & set
	public List<Personne> getAmis() {
		return amis;
	}

	public void setAmis(List<Personne> amis) {
		this.amis = amis;
	}

	public String getAvatar() {
		return avatar;
	}

	public void setAvatar(String avatar) {
		this.avatar = avatar;
	}

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getNom() {
		return nom;
	}

	public void setNom(String nom) {
		this.nom = nom;
	}

	public String getPrenom() {
		return prenom;
	}

	public void setPrenom(String prenom) {
		this.prenom = prenom;
	}

	public String getPseudo() {
		return pseudo;
	}

	public void setPseudo(String pseudo) {
		this.pseudo = pseudo;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getPasswd() {
		return passwd;
	}

	public void setPasswd(String passwd) {
		this.passwd = passwd;
	}
	
	
	//comparateurs
	@Override
	public boolean equals(Object obj) {
		if (obj == null) {
			return false;
		}
		if (getClass() != obj.getClass()) {
			return false;
		}
		final Personne other = (Personne) obj;
		if (this.id != other.id && (this.id == null || !this.id.equals(other.id))) {
			return false;
		}
		return true;
	}

	@Override
	public int hashCode() {
		int hash = 7;
		hash = 67 * hash + (this.id != null ? this.id.hashCode() : 0);
		return hash;
	}
	
}
